package com.example.scenictourback.dto;

import com.example.scenictourback.entity.Room;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class RoomDTO {
    
    private Integer id;
    private Integer hotelId;
    private String hotelName;
    private String type;
    private BigDecimal price;
    private Integer total;
    private Integer available;
    
    // 静态方法，将实体对象转为DTO对象
    public static RoomDTO fromEntity(Room room) {
        RoomDTO dto = new RoomDTO();
        dto.setId(room.getId());
        dto.setHotelId(room.getHotel().getId());
        dto.setHotelName(room.getHotel().getName());
        dto.setType(room.getType());
        dto.setPrice(room.getPrice());
        dto.setTotal(room.getTotal());
        dto.setAvailable(room.getAvailable());
        return dto;
    }
    
    // 静态方法，将实体列表转为DTO列表
    public static List<RoomDTO> fromEntities(List<Room> rooms) {
        return rooms.stream()
                .map(RoomDTO::fromEntity)
                .collect(Collectors.toList());
    }
} 